<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

<%
		Cookie[] cookies = request.getCookies();
		if(null ==cookies ||cookies.length ==1){
			
%>
		<form action="CookieController">
			用户名：<input type="text" name="username" value="scott">
			密码：<input typw="password" name="password" value="123">
			
			<input type="checkbox" name="passLogin">一分钟免登陆
			
			<input type="submit" value="登陆">
		</form>
		

 <%

		}else{
			
			out.print("读取cookies登陆"+"\n");
			
			//模拟登陆
			
			for(int index=0;index<cookies.length;index++){
			
				
				String name= cookies[index].getName();
				
			
				if("username".equals(name)){
					
					String value= cookies[index].getValue();
					request.setAttribute(name, value);
					out.println(name);
					out.println(value);
					
				}
				
				if("password".equals(name)){
					
					String value= cookies[index].getValue();
					request.setAttribute(name, value);
					
					out.println(name);
					out.println(value);
					
				}
			}
			
			/* response.sendRedirect("CookieController"); */
			request.getRequestDispatcher("CookieController").forward(request, response);  
		}			
			
%>

	

</body>
</html>